﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq.Mapping;
using System.Collections.Generic;
using System.Linq;

namespace G.Reader.Data
{
    [Table]
    public class BookInfo : BaseTable
    {
        private int id;

        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int ID
        {
            get
            {
                return id;
            }
            set
            {
                if (id != value)
                {
                    NotifyPropertyChanging("ID");
                    id = value;
                    NotifyPropertyChanged("ID");
                }
            }
        }


        private string bookName;
        /// <summary>
        /// 书本名称
        /// </summary>
        [Column]
        public string BookName
        {
            get
            {
                return bookName;
            }
            set
            {
                if (bookName != value)
                {
                    NotifyPropertyChanging("BookName");
                    bookName = value;
                    NotifyPropertyChanged("BookName");
                }
            }
        }



        private BookType bookType;
        /// <summary>
        /// 书本类型
        /// </summary>
        [Column]
        public BookType BookType
        {
            get
            {
                return bookType;
            }
            set
            {
                if (bookType != value)
                {
                    NotifyPropertyChanging("BookType");
                    bookType = value;
                    NotifyPropertyChanged("BookType");
                }
            }
        }



        private long size;
        /// <summary>
        /// 书本大小，单位为字节
        /// </summary>
        [Column]
        public long Size
        {
            get
            {
                return size;
            }
            set
            {
                if (size != value)
                {
                    NotifyPropertyChanging("Size");
                    size = value;
                    NotifyPropertyChanged("Size");
                }
            }
        }

        private string imageUrl;
        [Column]
        public string ImageUrl
        {
            get
            {
                return imageUrl;
            }
            set
            {
                if (imageUrl != value)
                {
                    NotifyPropertyChanging("ImageUrl");
                    imageUrl = value;
                    NotifyPropertyChanged("ImageUrl");
                }
            }
        }


        private string address;
        [Column]
        public string Address
        {
            get
            {
                return address;
            }
            set
            {
                if (address != value)
                {
                    NotifyPropertyChanging("Address");
                    address = value;
                    NotifyPropertyChanged("Address");
                }
            }
        }

        private double scrollHeight;
        /// <summary>
        /// 滚动条滑到的序号
        /// </summary>
        [Column]
        public double ScrollHeight
        {
            get
            {
                return scrollHeight;
            }
            set
            {
                if (scrollHeight != value)
                {
                    NotifyPropertyChanging("ScrollHeight");
                    scrollHeight = value;
                    NotifyPropertyChanged("ScrollHeight");
                }
            }
        }
        //private byte[] temp;
        //[Column]
        //public byte[] Temp
        //{
        //    get
        //    {
        //        return temp;
        //    }
        //    set
        //    {
        //        if (temp != value)
        //        {
        //            NotifyPropertyChanging("Temp");
        //            temp = value;
        //            NotifyPropertyChanged("Temp");
        //        }
        //    }
        //}

        public string Path
        {
            get { return System.IO.Path.Combine("Books", string.Format("{0}.book", this.ID)); }
        }
    }

    public enum BookType
    {
        TXT,
        RSS,
        XPS,
        /// <summary>
        /// 单篇的新闻
        /// </summary>
        News
    }
}
